package demo.entity;

import lombok.Data;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import java.sql.Timestamp;
import java.util.Date;

/**
 * 用于测试日期、时间
 * <p>
 * Created by 张少昆 on 2018/1/29.
 */
@Data
@Entity
@Table( name = "user" )
public class User {
    @Id
    @GeneratedValue( strategy = GenerationType.IDENTITY )
    private long id;
    private String name;
    @Temporal( TemporalType.TIMESTAMP )
    private Date birthday_a;
    @Temporal( TemporalType.DATE )
    private Date birthday_d;
    @Temporal( TemporalType.TIME )
    private Date birthday_t;

    private Date birthday;//TODO 默认对应datetime类型？

    @Column(columnDefinition = "timestamp")
    private long timestamp; //默认值是00000000
    @Column(columnDefinition = "timestamp")
    private Date timestamp_t; //要这么使用，在插入的时候才会有默认值（当前时间）


    //enum
    @Enumerated( EnumType.STRING )  //默认使用enum的数字，这里强行指定为字符串
    @Column( length = 5 )
    private Gender gender;
}
